<template>
	<view>
		<view class="uni-media-list">
			<view class="uni-media-list-body">
				<view class="uni-media-list-text-top">{{ recruit.ZW }}</view>
				<view class="uni-media-list-text-middle">
					<span v-if="recruit.SSDS">{{ recruit.SSDS }}</span> 
					<span v-if="recruit.NLYQ">{{ recruit.NLYQ }}</span>
					<span v-if="recruit.XQRS">{{ recruit.XQRS }}</span>
					<span v-if="recruit.ZCYQ">{{ recruit.ZCYQ }}</span>
				</view>
				<view class="uni-media-list-text-bottom">
					<text>{{ recruit.JGMC }}</text>
					<div>
						<!-- <uni-icons type="redo" size="20"></uni-icons>
						<uni-icons type="heart" size="20"></uni-icons> -->
					</div>
				</view>
				<uni-title type="h5" title="工作地址 "></uni-title>
				<view class="uni-media-list-text-content">
					<text>{{ recruit.GZDZ }}</text>
				</view>
				<uni-title type="h5" title="职称要求 "></uni-title>
				<view class="uni-media-list-text-content">
					<text>{{ recruit.ZCYQ }}</text>
				</view>
				<uni-title type="h5" title="专业要求 "></uni-title>
				<view class="uni-media-list-text-content">
					<text>{{ recruit.ZYYQ }}</text>
				</view>
				<uni-title type="h5" title="职位描述及技能要求 "></uni-title>
				<view class="uni-media-list-text-content">
					<text>{{ recruit.ZWMS }}</text><br/>
					<text>{{ recruit.JMYQ }}</text>
				</view>
				<uni-title type="h5" title="联系方式 "></uni-title>
				<view class="uni-media-list-text-content">
					<text>{{ recruit.LXDH }}</text>
				</view>
				<uni-title type="h5" title="其它 "></uni-title>
				<view class="uni-media-list-text-content">
					<text>{{ recruit.QT }}</text>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import apiConfig  from "/api/config.js"
	import CryptoJS from 'crypto-js'
	
	export default {
		data() {
			return {
				recruit:{}
			};
		},
		onLoad(option) {
			// 查询详情
			this.getRecruitDetail(option.id);
		},
		methods: {
			getRecruitDetail(id){
				const query = {
					action: 'getRecruitInfo',
					recruitId: id
				};
				uni.request({
					url: apiConfig.api_host + "/wsb/interface/txywryxc.do",
					data: query,
					success: data => {
						var decrypt = this.aes_decrypt(data.data)
						console.log("解密", decrypt);
						var rstData = JSON.parse(decrypt.replace(/[^\x20-\x7E\u4E00-\u9FFF]+/g, ""));
						console.log("招聘详情", rstData);
						if(rstData.code == 200){
							this.recruit = rstData.data;
						}
					},
					fail: (data, code) => {
						console.log('fail', data);
					}
				});
			},
			aes_encrypt: function(word){
				let keyStr = "abc654321abc===+";//加密密钥
				let ivStr  = "abc654321abc===+";//矢量
			    keyStr = keyStr ? keyStr : 'hfhfuu8dolv98bt6';
			    var key  = CryptoJS.enc.Utf8.parse(keyStr);
			    var iv   = CryptoJS.enc.Utf8.parse(ivStr);
			    // var srcs = CryptoJS.enc.Utf8.parse(word);
			    var encrypted = CryptoJS.AES.encrypt(word, key, {
			        iv:iv,
			        mode:CryptoJS.mode.CBC,
			        padding: CryptoJS.pad.Pkcs7});
			    return encrypted.toString();
			},
			 
			//解密  
			aes_decrypt: function(word){  
				let keyStr = "abc654321abc===+";//加密密钥
				let ivStr  = "abc654321abc===+";//矢量
			    keyStr = keyStr ? keyStr : 'hfhfuu8dolv98bt6';
			    var key  = CryptoJS.enc.Utf8.parse(keyStr);//
			    var iv   = CryptoJS.enc.Utf8.parse(ivStr);
			    // const restoreBase64 = word.replace(/\-/g,'+').replace(/_/g,'/');
			    var restoreBase64=word.replace(/[\r\n]/g,'');
			 
			    var decrypt = CryptoJS.AES.decrypt(restoreBase64, key, {
			        iv:iv,
			        mode:CryptoJS.mode.CBC,
			        padding: CryptoJS.pad.ZeroPadding});
			    return CryptoJS.enc.Utf8.stringify(decrypt).toString();
			}
		}
	};
</script>

<style>
	.uni-media-list {
		background-color: white;
	}
	.uni-media-list-logo {
		width: 180rpx;
		height: 140rpx;
	}
	
	.uni-media-list-body {
		height: auto;
		justify-content: space-around;
	}
	
	.uni-media-list-text-top {
		height: 60rpx;
		font-size: 29rpx;
		overflow: hidden;
		font-weight: bold;
	}
	.uni-media-list-text-middle {
		height: 65rpx;
		font-size: 28rpx;
		overflow: hidden;
	}
	.uni-media-list-text-middle span {
		background-color: rgb(241, 241, 241);
		font-size: 12px;
		padding: 5px;
		border-radius: 2px;
		margin-right: 5px;
		color: #4c4c4c;
	}
	
	.uni-media-list-text-bottom {
		height: 40rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		color:black;
		border-bottom: 2px solid rgb(241, 241, 241);
		font-weight: bold;
	}
	.uni-section .uni-section-header span {
		font-weight: bold;
	}
	.uni-section-header{
		font-weight: bold;
	}
	.uni-media-list-text-content {
		margin-left: 10px;
		font-size: 13px;
	}
</style>
